import bcrypt from 'bcrypt';

// 加密密码
export const hashPassword = async (password: string): Promise<string> => {
  const saltRounds = 5; // 计算复杂度，数值越高越安全但越慢
  return await bcrypt.hash(password, saltRounds);
};

// 验证密码
export const comparePassword = async (
  plainPassword: string,
  hashedPassword: string
): Promise<boolean> => {
  return await bcrypt.compare(plainPassword, hashedPassword);
};
